﻿using System.Data.Objects.DataClasses;
using JustinAngel.MetroBlog.Common.IoC;
using JustinAngel.MetroBlog.Services.DBContextContainer;

namespace JustinAngel.MetroBlog.Services.Repository
{
    public static class PersistExtensions
    {
        public static void Create<T>(this T entity)
            where T : EntityObject
        {
            IoC.Get<IRepository<T>>().Insert(entity);
        }

        public static void Delete<T>(this T entity)
            where T : EntityObject
        {
            IoC.Get<IRepository<T>>().Delete(entity);
        }

        public static void ForceSave<T>(this T entity)
          where T : EntityObject
        {
            IoC.Get<IDBContextContainer>().CommitChanges();
        }


        //public static IQueryable<BlogPost> Get()
        //{
        //    return IoC.Get<IRepository<BlogPost>>().Get();
        //}
    }
}
